package com.springboot.test.web.manage;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.test.common.response.Response;
import com.springboot.test.service.GoodsService;
import com.springboot.test.service.param.GoodsPageParam;
import com.springboot.test.service.result.GoodsDetailResult;
import com.springboot.test.service.result.GoodsPageResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

@RestController
@RequestMapping("manage/goods")
public class ManageGoodsController {
    @Resource
    private GoodsService goodsService;

    @PostMapping("page")
    public Response<Page<GoodsPageResult>> goodsPage(@RequestBody GoodsPageParam param){
        return Response.success(goodsService.goodsPage(param,1));
    }

    @GetMapping("update_status")
    public Response<Boolean> updateStatus(String goodsCode,Integer status,String reason){
        return Response.success(goodsService.adminUpdateStatus(goodsCode,status,reason));
    }

    @GetMapping("detail")
    public Response<GoodsDetailResult> goodsDetail(String goodsCode){
        return Response.success(goodsService.detailByCode(goodsCode));
    }

    @GetMapping("count")
    public Response<Integer> count(){
        return Response.success(goodsService.count());
    }

    @GetMapping("trade_count")
    public Response<Integer> tradeCount(){
        return Response.success(goodsService.tradeCount());
    }

    @GetMapping("trade_number")
    public Response<BigDecimal> tradeNumber(){
        return Response.success(goodsService.tradeNumber());
    }

}
